package com.jwell.panprovider.presenter

import com.jwell.driverapp.tools.BaseSubscriber
import com.jwell.driverapp.ui.base.BasePresenter
import com.jwell.panprovider.contract.CaptureContract
import com.jwell.panprovider.model.CaptureModel
import org.json.JSONObject
import org.reactivestreams.Subscription

/**
 * Created by 76577 on 2018/4/13.
 * 二维码扫描
 */
class CapturePresenter : CaptureContract.Presenter, BasePresenter<CaptureContract.View>() {
    private val model: CaptureModel by lazy {
        CaptureModel()
    }

    override fun unloading(id: String) {
        model.unloading(id, object : BaseSubscriber() {
            override fun setSubscription(s: Subscription) {
                mSubscription = s
            }

            override fun succeed(data: JSONObject) {
                getView()?.hideProgress()
                getView()?.upSucceed()
            }

            override fun onFailed(msg: String) {
                getView()?.hideProgress()
                getView()?.upFailed(msg)
            }
        })
    }
}